package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TCarportsell;
import com.ruoyi.system.domain.TWatergate;
import com.ruoyi.system.service.ITWatergateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Xiexingxie
 * @date 2022/12/8 下午 03:42
 */

@RestController
@RequestMapping("/system/watergate")
public class TWatergateController extends BaseController {

    private final static Logger log = LoggerFactory.getLogger(TWatergateController.class);

    @Autowired
    private ITWatergateService itWatergateService;

    @PreAuthorize("@ss.hasPermi('system:watergate:list')")
    @GetMapping("/getwatergatelist")
    public TableDataInfo getWatergateList(TWatergate tWatergate) {

        startPage();

        List<TWatergate> watergateList = itWatergateService.getWatergateList(tWatergate);
        log.debug("搜索条件：{}", tWatergate);
        return getDataTable(watergateList);

    }

    /**
     * 获取车位销售详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:watergate:query')")
    @GetMapping(value = "/{wid}")
    public AjaxResult getInfo(@PathVariable("wid") Integer wid)
    {
        log.debug("根据ID：{},查询信息", wid);
        return success(itWatergateService.selectTWatergateById(wid));
    }

    /**
     * 新增车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:watergate:add')")
    @Log(title = "车位销售", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWatergate tWatergate)
    {
        log.debug("新增的信息为：{}",tWatergate);
        return toAjax(itWatergateService.insertTWatergate(tWatergate));
    }

    /**
     * 修改车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:watergate:edit')")
    @Log(title = "车位销售", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWatergate tWatergate)
    {
        log.debug("修改的信息为：",tWatergate);
        return toAjax(itWatergateService.updateTWatergate(tWatergate));
    }

    /**
     * 删除车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:watergate:remove')")
    @Log(title = "车位销售", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        log.debug("删除的ID为：{}",ids);
        return toAjax(itWatergateService.deleteTWatergateByIds(ids));
    }

}
